<!--变更项目保存-->
<template>
  <div style="height: 100%; overflow: hidden">
    <el-breadcrumb class="ne-padding-t-10" separator="/">
      <el-breadcrumb-item>首页</el-breadcrumb-item>
      <el-breadcrumb-item>已改单销售品列表</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="app-container m-content-box">
      <step-nav
        style="margin-bottom: 0.1rem"
        justify="center"
        :active="stepNav2.active"
        :colSize="10"
        :step-data="stepNav2.stepData"
      ></step-nav>
      <more-panel
        ref="morepanel"
        formRef="adodrFrom"
        :formModel="FormModel"
        :formRule="formRule"
        :boxShadow="false"
        title="订单项信息"
        clktext="详细内容"
      >
        <h1 slot="fixed">
          <el-row>
            <el-col :span="8" class="line">
              <el-form-item label="流水号">
                <el-input
                  clearable
                  v-model="FormModel.custSoNumber"
                  :disabled="true"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="受理运营商" prop="orderSourceId">
                  <el-select
                    filterable
                    v-model="FormModel.orderSourceId"
                    placeholder="请选择"
                    style="width: 100%"
                    @change="slyys"
                  >
                    <el-option
                      v-for="item in operatorsList"
                      :key="item.attrValue"
                      :label="item.attrValueName + ''"
                      :value="item.attrValue + ''"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8" class="line">
              <el-form-item class="clearfix" label="客户名称" required>
                <el-row>
                  <el-col :span="20">
                    <el-input
                      v-model="FormModel.custName"
                      class="left"
                      @change="khmc"
                      :disabled="true"
                    />
                  </el-col>
                  <el-col :span="4">
                    <a
                      href="javascript:;"
                      style="padding-left: 10px; color: blue"
                      >查看</a
                    >
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item
                class="clearfix"
                label="客户联系人"
                prop="orderContactInfo[0].contactName"
              >
                <el-row>
                  <el-col :span="20">
                    <el-input
                      v-model="FormModel.orderContactInfo[0].contactName"
                      @change="khlxr"
                      class="left"
                    />
                  </el-col>
                  <el-col :span="4">
                    <a
                      href="javascript:;"
                      style="padding-left: 10px; color: blue"
                      >查看</a
                    >
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item
                label="客户联系电话"
                prop="orderContactInfo[0].officePhone"
              >
                <el-input
                  clearable
                  v-model="FormModel.orderContactInfo[0].officePhone"
                  @change="khcontact"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8" class="line">
              <el-form-item
                class="clearfix"
                label="客户地址"
                prop="orderContactInfo[0].contactAddress"
              >
                <el-row>
                  <el-col :span="20">
                    <el-input
                      v-model="FormModel.orderContactInfo[0].contactAddress"
                      class="left"
                      @change="khaddress"
                      :disabled="custdisabled"
                    />
                  </el-col>
                  <el-col :span="4">
                    <a
                      href="javascript:;"
                      style="padding-left: 10px; color: blue"
                      >查看</a
                    >
                  </el-col>
                </el-row>
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="客户经理" prop="custManageName">
                  <!-- <input-grid
                    v-model="FormModel.custManagerName"
                    sqlCode="findCust"
                    @getrow="
                      (val) => {
                        FormModel.custManagerId = val;
                      }
                    "
                  /> -->
                  <input-dialog
                    v-model="FormModel.custManageName"
                    text="staffName"
                    @getrow="getRowCustManageHandler"
                    @loadata="loadCustManageOptions"
                    :config="custManageConfig"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="项目经理" prop="busiManageName">
                  <!-- <input-grid
                    v-model="FormModel.busiManageName"
                    sqlCode="findCust"
                    @getrow="
                      (val) => {
                        FormModel.busiManagerId = val;
                      }
                    "
                  /> -->
                  <input-dialog
                    v-model="FormModel.busiManageName"
                    text="staffName"
                    @getrow="getRowBusiManageHandler"
                    @loadata="loadBusiManageOptions"
                    :config="busiManageConfig"
                  />
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="商机" prop="saleName">
                  <!-- <input-grid
                    v-model="FormModel.saleName"
                    sqlCode="findCust"
                    @getrow="
                      (val) => {
                        FormModel.saleId = val;
                      }
                    "
                  /> -->
                  <input-dialog
                    v-model="FormModel.saleName"
                    text="staffName"
                    @getrow="getRowSaleHandler"
                    @loadata="loadSaleOptions"
                    :config="saleConfig"
                    :isDisabled="FormModel.saleName != '' ? true : false"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <!-- <el-form-item label="合同编码" prop="contactCd"> -->
                <el-form-item label="合同编码">
                  <input-dialog
                    v-model="FormModel.contactCd"
                    text="contactCd"
                    @getrow="getRowContactCdHandler"
                    @loadata="loadContactCdOptions"
                    :config="contactCdConfig"
                    :isDisabled="FormModel.contactCd != '' ? true : false"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item label="合同名称">
                <el-input
                  clearable
                  v-model="FormModel.contactName"
                  :disabled="ctNameDisable"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="MSS项目编码">
                  <input-dialog
                    v-model="FormModel.projectId"
                    text="itemcode"
                    @getrow="getRowProjectNameHandler"
                    @loadata="loadProjectNameOptions"
                    :config="projectNameConfig"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="营销项目编码">
                  <input-dialog
                    v-model="FormModel.marketProjectCode"
                    text="marketProjectCode"
                    @getrow="getMarketProjectCode"
                    @loadata="loadMarketProjectOptions"
                    :config="marketProjectNameConfig"
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item label="营销项目名称">
                <el-input
                  clearable
                  v-model="FormModel.marketProjectName"
                  disabled
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" class="line">
              <div class="grid-content bg-purple">
                <el-form-item label="营销子项目编码">
                  <input-dialog
                    v-model="FormModel.marketSubprojectCode"
                    text="marketSubprojectCode"
                    @getrow="getmarketSubprojectCode"
                    @loadata="loadMarketSubprojectOptions"
                    :config="marketSubprojectNameConfig"
                    :infoTip='infoTip'
                    infoText='请先选择营销项目编码！'
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8" class="line">
              <el-form-item label="营销子项目名称">
                <el-input
                  clearable
                  v-model="FormModel.marketSubprojectName"
                  disabled
                />
              </el-form-item>
            </el-col>
          </el-row>
        </h1>
        <!-- 可隐藏区域 -->
        <el-col :span="8" class="line">
          <div class="grid-content bg-purple">
            <el-form-item class="ne-line" label="是否跨域业务">
              <el-radio-group
                class="column-center"
                v-model="FormModel.oneSubFlag"
              >
                <el-radio size="mini" :label="1">是</el-radio>
                <el-radio size="mini" :label="2">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </div>
        </el-col>
        <!-- <el-col :span="8" class="line">
          <el-form-item label="客户传真">
            <el-input clearable v-model="custModel.custMsg.contactFax" />
          </el-form-item>
        </el-col>
        <el-col :span="8" class="line">
          <el-form-item label="客户EMAIL">
            <el-input clearable v-model="custModel.custMsg.contactEmail" />
          </el-form-item>
        </el-col>
        <el-col :span="8" class="line">
          <div class="grid-content bg-purple">
            <el-form-item
              class="ne-line"
              label="是否为曲线一站服务需求"
              prop="type"
            >
              <el-radio-group
                class="column-center"
                v-model="orderModel.isCountyFlag"
              >
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </div>
        </el-col> -->
        <!-- <el-col :span="8" class="line">
          <div class="grid-content bg-purple">
            <el-form-item label="合同编号类型">
              <el-select
                v-model="FormModel.contactNumberType"
                placeholder="请选择"
                style="width: 100%"
              >
                <el-option
                  v-for="item in contactNumTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </div>
        </el-col> -->
        <el-col :span="8" class="line">
          <div class="grid-content bg-purple">
            <el-form-item label="项目名称" prop="type">
              <el-input
                v-model="FormModel.projectName"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </div>
        </el-col>
        <el-col :span="8" class="line">
          <el-form-item label="项目描述">
            <el-input clearable v-model="FormModel.bussDesc" />
          </el-form-item>
        </el-col>
        <el-col :span="24" class="line">
          <el-form-item label="备注">
            <el-input type="textarea" v-model="FormModel.remark"></el-input>
          </el-form-item>
        </el-col>
      </more-panel>

      <el-row>
        <el-col :span="24">
          <div class="clearfix table-title">
            <p class="tbl-title left">销售品信息</p>
            <div class="btn-grop right">
              <el-button type="primary" size="mini" @click="continuGD"
                >继续变更</el-button
              >
              <el-button type="primary" size="mini" @click="deleteClick"
                >删除</el-button
              >
            </div>
          </div>
        </el-col>
        <el-col :span="24">
          <div>
            <el-table
              :header-cell-style="{ background: '#F2F2F2', color: '#333' }"
              border
              @selection-change="handleSelectionChange"
              style="width: 100%"
              :data="tableData"
            >
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column label="操作" fixed="left">
                <template slot-scope="scope">
                  <span class="bgrz" @click="Openbgrz(scope.row)"
                    >变更日志
                  </span>
                  <el-dialog
                    :width="changeConfig.width"
                    :title="changeConfig.title"
                    :visible.sync="changeConfig.dialogFormVisible"
                    :center="changeConfig.center"
                    :lock-scroll="changeConfig.scroll"
                    :close-on-click-modal="changeConfig.close"
                    :modal-append-to-body="changeConfig.tobody"
                    custom-class="changeDialog"
                  >
                    <DicTable
                      ref="dictable"
                      stripe
                      :columnData="changeConfig.tableColumns"
                      :tableData="changeConfig.tableData"
                      :loading="changeConfig.tableLoading"
                      :currentPage="Number(changeConfig.tablePage.currentPage)"
                      :pageSize="Number(changeConfig.tablePage.pageSize)"
                      :totalResult="Number(changeConfig.tablePage.rowCount)"
                      :pager="true"
                      @on-page-change="handlePageChange"
                    >
                    </DicTable>
                  </el-dialog>
                </template>
              </el-table-column>
              <el-table-column
                label="销售品名称"
                prop="offerName"
                align="center"
                fixed
              ></el-table-column>

              <el-table-column label="要求完成时间" align="center">
                <template slot-scope="scope">
                  <span
                    v-if="
                      scope.row.reqOrderDate && scope.row.reqOrderDate != ''
                    "
                    >{{ scope.row.reqOrderDate }}</span
                  >
                  <span v-else>{{ scope.row.orderDate }}</span>
                </template>
              </el-table-column>
              <el-table-column
                label="通达地点"
                prop="regionRange"
                align="center"
              ></el-table-column>
              <el-table-column
                label="登记事项"
                prop="serviceOfferName"
                align="center"
              ></el-table-column>
              <el-table-column
                label="设备号"
                prop="accNum"
                align="center"
              ></el-table-column>
              <el-table-column
                label="甲端用户名称"
                prop="useCustName"
                align="center"
              ></el-table-column>
              <el-table-column
                label="甲端联系人"
                prop="contactName"
                align="center"
              ></el-table-column>
              <el-table-column
                label="甲端联系人电话"
                prop="mobilePhone"
                align="center"
              ></el-table-column>
              <el-table-column
                label="甲端装机地址"
                prop="addressDesc"
                align="center"
                show-overflow-tooltip
              ></el-table-column>
              <el-table-column
                label="乙端用户名称"
                prop="zUseCustName"
                align="center"
              ></el-table-column>
              <el-table-column
                label="乙端联系人"
                prop="zContactName"
                align="center"
              ></el-table-column>
              <el-table-column
                label="乙端联系人电话"
                prop="zMobilePhone"
                align="center"
              ></el-table-column>
              <el-table-column
                label="乙端装机地址"
                prop="zAddressDesc"
                align="center"
                show-overflow-tooltip
              ></el-table-column>
              <el-table-column
                label="速率"
                prop="rate"
                align="center"
                fixed="right"
              ></el-table-column>
            </el-table>
            <el-row
              type="flex"
              class="row-bg mar-15"
              justify="center"
              style="margin-bottom: 0.7rem"
            >
              <el-col :span="10">
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="parseInt(pageInfo.pageIndex)"
                  background
                  :page-sizes="[5, 10, 15, 20]"
                  :page-size="10"
                  :total="parseInt(pageInfo.rowCount)"
                  layout="total, sizes, prev, pager, next, jumper"
                >
                </el-pagination>
              </el-col>
            </el-row>
          </div>
        </el-col>
      </el-row>
      <div class="footBtn">
        <el-button
          type="primary"
          plain
          v-loading.fullscreen.lock="loading"
          @click="createProject(false)"
          >保存</el-button
        >
        <el-button
          type="primary"
          @click="doCreateAndVerify"
          plain
          v-loading.fullscreen.lock="loading"
          >保存并送审核</el-button
        >
      </div>
    </div>
    <!-- <fix-nav></fix-nav> -->

    <el-dialog
      class="ne-pending-task"
      append-to-body
      :width="isContent.width"
      :top="isContent.top"
      :title="isContent.title"
      v-if="pendItemVisible"
      :visible.sync="pendItemVisible"
      :before-close="digClose"
    >
      <component
        :show.sync="pendItemVisible"
        :is="isContent.content"
        @close="fun"
        @update:show="jumpCustOrder"
        :ODKInfo="isContent.ODKInfo"
        :CTOInfo="isContent.CTOInfo"
      ></component>
    </el-dialog>
  </div>
</template>

<script>
// import FixNav from "@/components/order/FixNav";
import MorePanel from "@/components/public/MorePanel";
import StepNav from "@/components/public/StepNav";
import OrderService from "@/api/order/OrderService.js";
import DeletePage from "@/components/custorder/DeletePage.vue";
import CopyOrder from "@/components/custorder/CopyOrder.vue";
import inputDialog from "@/components/public/forms/inputDialog";
import templateQuery from "@/components/order/templateQuery/index";
import DicTable from "@/components/public/DicTable";
import { mapGetters, mapMutations, mapState } from "vuex";
import SendAudit from "@/components/custorder/pengding/SendAudit";
import { Loading } from "element-ui";
export default {
  name: "OrderAdd",
  components: {
    MorePanel,
    inputDialog,
    StepNav,
    // FixNav,
    DeletePage,
    CopyOrder,
    templateQuery,
    DicTable,
    SendAudit,
  },
  async created() {
    // this.$store.commit("orders/SET_STEPACTIVE2", 2);
    Object.assign(this.FormModel, {
      staffid: this.user.staffId,
      createStaff: this.user.staffId,
      orgId: this.user.orgId,
      accepteRegionId: this.user.regionId,
      accepteLanId: this.user.regionId,
    });

    // 继续变更后续优化
    let flag = this.$route.query.flag || "";
    if (flag == "1") {
       debugger;
      //批量变更导航返回
    } else {
      debugger;
      this.backInfo = this.$route.query.customerOrder || {};
      this.FormModel.custSoNumber = this.backInfo.custSoNumber || "";
      this.FormModel.custId = this.backInfo.custId || "";
      this.FormModel.custOrderId = this.backInfo.custOrderId || "";
      //变更页面回显
      let conditions = {
        modType: JSON.parse(sessionStorage.getItem("ppmCondition")).modType, //非正常变更50200002,正常变更50200003
        interFaceType: "ORDER",
        sqlId: 2021052110,
        custId: this.FormModel.custId || "",
        custSoNumber: this.FormModel.custSoNumber,
      };
      let resList = await this.getModProjectInfo(conditions);
      //业务经理默认
      this.FormModel.busiManagerId = resList.busiManagerId || "";
      this.SET_BUSIMANAGERID(resList.busiManagerId || "");
      this.SET_XBUSIMANAGEMODEL({
        busiManagerId: resList.busiManagerId || "",
        busiManageName: resList.busiManagerName || "",
      });
      //客户经理默认
      this.FormModel.custManagerId = resList.custManagerId || "";
      this.SET_CUSTMANAGERID(resList.custManagerId || "");
      this.SET_XCUSTMANAGEMODEL({
        custManagerId: resList.custManagerId || "",
        custManageName: resList.custManagerName || "",
      });
      if (this.backInfo.custOrderId) {
        resList.custOrderId = this.FormModel.custOrderId;
        resList.custSoNumber = this.FormModel.custSoNumber;
        resList.custId = this.FormModel.custId;
        sessionStorage.setItem("FormModel", JSON.stringify(resList));
      }
    }
    let storageFormModel = JSON.parse(sessionStorage.getItem("FormModel"));
    this.FormModel.custSoNumber = storageFormModel.custSoNumber || ""; //流水号
    this.FormModel.custOrderId = storageFormModel.custOrderId || ""; //custOrderId
    if (
      JSON.parse(sessionStorage.getItem("ppmCondition")).serviceOfferId ==
      5010300062
    ) {
      this.getHtInfor();
    } else {
      this.FormModel.contactCd = storageFormModel.contractCd || ""; //合同cd,
      this.FormModel.contactName = storageFormModel.contractName || ""; //合同名字
      this.FormModel.contactId = storageFormModel.contractId || ""; //合同id,
      this.FormModel.projectId = storageFormModel.projectCode || ""; //项目ID，保存，MSS项目编码回显
      this.FormModel.projectName = storageFormModel.projectsName || ""; //项目名称
      this.FormModel.bussDesc = storageFormModel.bussDesc || ""; //项目描述
    }
    
    this.FormModel.contactNumberType = storageFormModel.contactNumberType || ""; //合同编号类型,
    this.FormModel.custName =
      (storageFormModel.custName || "") != ""
        ? storageFormModel.custName
        : this.orderPosInfo.custMsg.custName; //客户名称
    this.FormModel.custId =
      (storageFormModel.custId || "") != ""
        ? storageFormModel.custId
        : this.orderPosInfo.custMsg.custId; //客户ID
    this.FormModel.orderContactInfo[0].contactAddress =
      (storageFormModel.custAddr || "") != ""
        ? storageFormModel.custAddr
        : this.orderPosInfo.custMsg.custAddr || ""; //联系人地址
    if (this.FormModel.orderContactInfo[0].contactAddress == "") {
      this.custdisabled = false;
    } else {
      this.custdisabled = true;
    }
    this.FormModel.oldPartyCode = storageFormModel.oldPartyCode || ""; //客户code
    this.FormModel.orderContactInfo[0].officePhone =
      (storageFormModel.contactMobilePhone || "") != ""
        ? storageFormModel.contactMobilePhone
        : this.orderPosInfo.custMsg.contactMobilePhone; //联系电话
    this.FormModel.orderContactInfo[0].contactName =
      (storageFormModel.contactName || "") != ""
        ? storageFormModel.contactName
        : this.orderPosInfo.custMsg.contactName; //客户联系人
    this.FormModel.orderContactInfo[0].contactEmail =
      (storageFormModel.contactEmail || "") != ""
        ? storageFormModel.contactEmail
        : this.orderPosInfo.custMsg.contactEmail; //客户联系邮箱
    this.saleName = storageFormModel.contractName || ""; //合同名称
    this.FormModel.saleId = storageFormModel.saleCd || ""; //商机
    this.FormModel.saleName = storageFormModel.saleName || ""; //商机编码
    this.FormModel.orderSourceId = storageFormModel.orderSourceId || "10000"; //受理运营商

    this.FormModel.extSystem = storageFormModel.extSystem || ""; //项目描述

    this.FormModel.custManagerId = storageFormModel.custManagerId || "";

    if (JSON.parse(sessionStorage.getItem("ppmCondition")).serviceOfferId == 4040100085 ) {//客户名称变更特殊处理
      this.FormModel.custName = (this.CUST_INFO_CHANGE.custName || "") != "" ? this.CUST_INFO_CHANGE.custName : this.orderPosInfo.custMsg.custName; //客户名称
      this.FormModel.custId =  (this.CUST_INFO_CHANGE.custId || "") != "" ? this.CUST_INFO_CHANGE.custId : this.orderPosInfo.custMsg.custId; //客户ID
      this.FormModel.orderContactInfo[0].contactAddress = (this.CUST_INFO_CHANGE.custAddr || "") != "" ? this.CUST_INFO_CHANGE.custAddr : this.orderPosInfo.custMsg.custAddr || ""; //联系人地址
      if (this.FormModel.orderContactInfo[0].contactAddress == "") {
        this.custdisabled = false;
      } else {
        this.custdisabled = true;
      }
      this.FormModel.oldPartyCode = this.CUST_INFO_CHANGE.oldPartyCode || ""; //客户code
      this.FormModel.orderContactInfo[0].officePhone = (this.CUST_INFO_CHANGE.contactMobilePhone || "") != "" ? this.CUST_INFO_CHANGE.contactMobilePhone : this.orderPosInfo.custMsg.contactMobilePhone; //联系电话
      this.FormModel.orderContactInfo[0].contactName = (this.CUST_INFO_CHANGE.contactName || "") != "" ? this.CUST_INFO_CHANGE.contactName : this.orderPosInfo.custMsg.contactName; //客户联系人
      this.FormModel.orderContactInfo[0].contactEmail = (this.CUST_INFO_CHANGE.contactEmail || "") != "" ? this.CUST_INFO_CHANGE.contactEmail : this.orderPosInfo.custMsg.contactEmail; //客户联系邮箱
    }
    // 销售品信息,下方表格数据
    if (this.FormModel.custSoNumber) {
      this.qryOrderItem();
    }
    // InputDialog控件选择的值将被vuex管理,首次加载时去读一次
    Object.assign(this.FormModel, this.xCustManageModel);
    Object.assign(this.FormModel, this.xBusiManageModel);
    //受理运营商
    let params = { attrId: "100010765", productId: "" };
    this.getAttrValueList(params);
  },

  data() {
    return {
      backInfo: {}, //受理成功传回
      deleteObj: {
        custSoNumber: "",
        orderItemIds: "",
        staffId: "",
        custId: "",
      },
      FormModel: {
        marketProjectCode:'',//营销项目编码
        marketProjectName:'',//营销项目名称
        marketProjectId:'',//营销项目Id
        marketSubprojectCode:'',//营销子项目编码
        marketSubprojectName:'',//营销子项目名称
        subProjectId:'',//营销子项目id
        oldPartyCode:'',//客户编码
        custOrderId: "", //-----客户订单id  销售品保存页面带回建议页面增加隐藏 ✔
        custSoNumber: "", // -----流水号  销售品保存页面带回 ✔
        operType: "1000", //必传，1000新增，1200变更（单号必传），1300保持不变（单号必传，其余字段需要修改的传入）
        custOrderType:
          JSON.parse(sessionStorage.getItem("ppmCondition")).serviceOfferId ==
          "4020100000"
            ? "50200005"
            : JSON.parse(sessionStorage.getItem("ppmCondition")).modType, //新装订购传 50200001
        orderSourceId: "10000", //订单受理运营商 页面取
        staffid: "", //当前登录员工id  缓存里面取 staffid（具体缓存里面存的字段名是啥还没确定）
        createStaff: "",
        orgId: "", //当前登录组织  缓存里面取 orgId
        accepteRegionId: "", // ---先空着
        accepteLanId: "", //----先空着
        custName: "", //客户名称
        custId: "", //--客户ID  客户定位页面传过来的
        sysSource: "1000", //来源系统，固定1000
        channelId: "10", //渠道：先空 后续补充
        orderSource: "1000", //订单来源"1000"	固定1000
        bussDesc: "", //--项目描述
        remark: "", // 备注  页面取
        contactId: "", //合同id页面取
        contactCd: "", //合同页面取
        contactName: "", //--合同名称页面取
        contactNumberType: "", //合同编号类型
        projectId: "", //选择项目弹窗会带回 页面取
        projectName: "", //选择项目弹窗会带回 页面取
        projectManage: "", //--选择项目弹窗会带回
        saleId: "", // --客户定位页面带回    没有为空
        extCustOrderId: "", //--空
        custManagerId: "", //--页面客户经理 存ID 页面取
        custManageName: "", //--页面客户经理 存ID 页面取
        busiManagerId: "", //--页面业务经理 存ID 页面取
        busiManageName: "", //--页面业务经理 存ID 页面取
        isCountyFlag: "", //是否区县一站服务 页面取
        oneSubFlag: "6", //是否跨域业务  页面取
        extSystem: "10", //受理渠道
        orderContactInfo: [
          {
            contactType: "1", //--客户联系人类型 默认1 TODO:需要对
            contactName: "", //--联系人名字 页面取
            homePhone: "", //--空
            officePhone: "", //--联系人邮箱 页面取
            contactEmail: "", //--客户email 页面取
            fax: "", //--客户传真 页面取
            locationId: "", //--客户定位页面带回
            contactAddress: "", // 客户地址页面取
          },
        ],
        custMsg: {},
      },
      showSales: true,
      topList: [],
      pendItemVisible: "",
      isContent: {},
      catalogId: 71, //查询销售品列表的固定值：代表订购
      loading: false,

      importLoading: false,
      custdisabled: false, //客户地址是否可修改
      ctNameDisable: true, //合同名称是否可修改
      selectList: [],
      importRules: {
        waresType: [
          { required: true, message: "请先选择产品类型", trigger: "change" },
        ],
      },
      importForm: {
        waresType: null, //产品类型對象
        radio: 0, //补导入
        uploadResult: "", //结果提示
        uploadClear: "", //详细结果提示
      },
      file: {},
      bufferLoading: true,

      isCheckedFileBtn: true,
      fileList: [],
      multipleSelection: [],
      // 分页模型
      pageInfo: {
        pageIndex: 1,
        pageSize: 10,
        rowCount: 0,
      },

      changeConfig: {
        width: "50%", //弹窗宽度
        title: "变更日志", //弹窗标题
        dialogFormVisible: false, //是否显示 Dialog弹窗
        center: true, //内容是否居中
        scroll: true,
        close: false,
        tobody: false,
        tableColumns: [
          { field: "ATTR_NAME_ALL", title: "属性名称", width: "33%" },
          { field: "attrValueNew", title: "新属性值", width: "33%" },
          { field: "attrValueOld", title: "属性原值", width: "33%" },
        ],
        tableData: [],
        tableLoading: false,
        tablePage: {
          currentPage: 1,
          pageSize: 10,
          totalResult: 0,
        },
      },

      //FIXME: 运营商列表
      operatorsList: [],

      //FIXME: 合同编号类型列表
      contactNumTypeList: [
        { value: 1, label: "合同编号类型1" },
        { value: 2, label: "合同编号类型2" },
      ],

      formRule: {
        orderSourceId: [
          { required: true, message: "受理运营商不能为空", trigger: "change" },
        ],
        custName: [
          { required: true, message: "客户名称不能为空", trigger: "blur" },
        ],
        "orderContactInfo[0].contactName": [
          { required: true, message: "客户联系人不能为空", trigger: "blur" },
        ],
        "orderContactInfo[0].officePhone": [
          { required: true, message: "客户联系电话不能为空", trigger: "blur" },
        ],
        "orderContactInfo[0].contactAddress": [
          { required: true, message: "客户地址不能为空", trigger: "blur" },
        ],
        custManageName: [
          { required: true, message: "客户经理不能为空", trigger: "change" },
        ],
        busiManageName: [
          { required: true, message: "项目经理不能为空", trigger: "change" },
        ],
        /*projectId: [
          { required: true, message: "MSS项目编码不能为空", trigger: "change" },
        ],*/
        contactCd: [
          { required: false, message: "合同编码不能为空", trigger: "change" },
        ],
      },
      tableData: [],

      /**
       * 业务经理选项配置
       */
      busiManageConfig: {
        title: "项目经理选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "staffCode",
              title: "项目经理编码",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "staffName",
              title: "项目经理名称",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "staffCode", title: "项目经理编码", width: "40%" },
          { field: "staffName", title: "项目经理名称", width: "40%" },
        ],
      },

      /**
       * 客户经理选项配置
       */
      custManageConfig: {
        title: "客户经理选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "staffCode",
              title: "客户经理编码",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "staffName",
              title: "客户经理名称",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "staffCode", title: "客户经理编码", width: "40%" },
          { field: "staffName", title: "客户经理名称", width: "40%" },
        ],
      },

      /**
       * 项目经理选项配置
       */
      projectManageConfig: {
        title: "项目经理选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "staffCode",
              title: "项目经理名称",
              itemRender: {
                name: "input",
                attrs: { placeholder: "请输入名称" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "staffCode", title: "项目经理编码", width: "40%" },
          { field: "staffName", title: "项目经理名称", width: "40%" },
        ],
      },

      /**
       * 项目名称选项配置
       */
      projectNameConfig: {
        title: "MSS项目信息",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "itemcode",
              title: "编码",
              itemRender: {
                name: "input",
                attrs: { placeholder: "请输入名称" },
              },
            },
            {
              field: "itemname",
              title: "名称",
              itemRender: {
                name: "input",
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "itemcode", title: "项目编码", width: "40%" },
          { field: "itemname", title: "项目名称", width: "40%" },
        ],
      },

      /**
       * 商机选项配置
       */
      saleConfig: {
        title: "商机选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "staffCode",
              title: "商机编码：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "staffName",
              title: "商机名称：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {}, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "staffCode", title: "商机编码", width: "40%" },
          { field: "staffName", title: "商机名称", width: "40%" },
        ],
      },

      /**
       * 合同编码选项配置
       */
      contactCdConfig: {
        title: "合同编码选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "contractcode",
              title: "合同编码：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "contractname",
              title: "合同名称：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {
            contractcode: "",
            contractname: "",
          }, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "contractcode", title: "合同编码", width: "40%" },
          { field: "contractname", title: "合同名称", width: "40%" },
        ],
      },
      //营销项目配置
      marketProjectNameConfig:{
        title: "营销项目选项",
        tableData: [],
        tableForm: {
          items: [
            {
              field: "PMCODE",
              title: "项目编码：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              field: "PMNAME",
              title: "项目名称：",
              itemRender: {
                name: "input",
                attrs: { placeholder: "" },
              },
            },
            {
              itemRender: {
                name: "$button",
                props: { content: "查询", type: "submit", status: "primary" },
              },
            },
          ],
          data: {
            PMCODE: "",
            PMNAME: "",
          }, //这个data一定要加，否则无法获取查询参数
        },
        tableColumn: [
          { field: "pmCode", title: "营销项目编码", width: "20%" },
          { field: "pmName", title: "营销项目名称", width: "20%" },
          { field: "pmId", title: "营销项目ID", width: "20%" },
          { field: "pmCustManager", title: "客户经理名称", width: "20%" },
          { field: "pmManager", title: "项目经理名称", width: "20%" },
        ],
      },
      //营销子项目配置
      marketSubprojectNameConfig:{
        title: "营销子项目选项",
        tableData: [],
        tableForm: {},
        tableColumn: [
          { field: "initProductCode", title: "营销项目编码", width: "20%" },
          { field: "productName", title: "营销项目名称", width: "20%" },
        ],
      },

      /**
       * 送审核参数收集
       */
      verifyModel: null,
      row: {}, //选中的行
      infoTip:true,//营销子项目编码是否可选
    };
  },
  computed: {
    
    ...mapState("orders", ["elecLabel", "orderPosInfo","CUST_INFO_CHANGE"]),
    ...mapState("user", ["user"]),
    ...mapState("orders", ["stepNav2"]),
    ...mapState("orderAdd", ["xCustManageModel", "xBusiManageModel"]),
  },

  methods: {
    ...mapMutations("user", ["SET_BUSIMANAGERID", "SET_CUSTMANAGERID"]),
    ...mapMutations("orders", [
      "SET_DEALTYPE",
      "SET_QRYTYPE",
      "SET_QRYVALUE",
      "SET_ORDERSTAGEID",
    ]),
    ...mapMutations("orderAdd", [
      "CLEAR_XMODEL",
      "SET_XCUSTMODEL",
      "SET_XCUSTMANAGEMODEL",
      "SET_XBUSIMANAGEMODEL",
      "SET_XPROJECTMODEL",
      "SET_XCONTACTMODEL",
      "SET_XSALEMODEL",
      "SET_XORDERMODEL",
    ]),
    //获取合同信息
    async getHtInfor() {
      let storageFormModel = JSON.parse(sessionStorage.getItem("FormModel"));
      let res = await OrderService.executeSql({
        interFaceType: "ORDER",
        sqlId: "2021080201",
        paramStr:
          "custId:" +
          storageFormModel.custId +
          ";" +
          "custSoNumber:" +
          storageFormModel.custSoNumber,
      });
      if (res.code == 200) {
        this.FormModel.contactCd =
          res.meta.resList.executeSqlResps.length > 0
            ? res.meta.resList.executeSqlResps[0].contactCd
            : ""; //合同cd,
        this.FormModel.contactName =
          res.meta.resList.executeSqlResps.length > 0
            ? res.meta.resList.executeSqlResps[0].contactName
            : ""; //合同名字
        this.FormModel.contactId =
          res.meta.resList.executeSqlResps.length > 0
            ? res.meta.resList.executeSqlResps[0].contactId
            : ""; //合同id,
        this.FormModel.projectId =
          res.meta.resList.executeSqlResps.length > 0
            ? res.meta.resList.executeSqlResps[0].projectId
            : ""; //项目ID，保存，MSS项目编码回显
        this.FormModel.projectName =
          res.meta.resList.executeSqlResps.length > 0
            ? res.meta.resList.executeSqlResps[0].projectsName
            : ""; //项目名称
        this.FormModel.bussDesc =
          res.meta.resList.executeSqlResps.length > 0
            ? res.meta.resList.executeSqlResps[0].bussDesc
            : ""; //项目描述
        if (this.FormModel.contactCd) {
          this.ctNameDisable = true;
        }
      }
    },
    fun() {
      
      this.pendItemVisible = false;
      this.qryOrderItem();
    },
    //审核弹窗关闭后跳转到销售页面
    jumpCustOrder() {
      if (this.isContent.content == "SendAudit") {
        this.$router.push({ name: `custinfo` });
      }
    },
    //审核弹窗关闭后跳转到销售页面
    digClose() {
      if (this.isContent.content == "SendAudit") {
        this.$router.push({ name: `custinfo` });
      }
    },
    //变更页面回显
    async getModProjectInfo(params) {
      debugger;
      const result = await OrderService.qryModProjectInfo(params);
      let resList = {};
      if (result.code == 200) {
        if (result.meta.resList.executeSqlResps.length > 0) {
          resList = result.meta.resList.executeSqlResps[0];
          this.FormModel.marketProjectCode = resList.marketProjectCode ? resList.marketProjectCode : '';
          this.FormModel.marketProjectName = resList.marketProjectName ? resList.marketProjectName : '';
          this.FormModel.marketProjectId = resList.marketProjectId ? resList.marketProjectId : '';
          this.FormModel.marketSubprojectCode = resList.marketSubprojectCode ? resList.marketSubprojectCode : '';
          this.FormModel.marketSubprojectName = resList.marketSubprojectName ? resList.marketSubprojectName : '';
          this.FormModel.subProjectId = resList.subProjectId ? resList.subProjectId : '';
          if(this.FormModel.marketProjectId){
            this.infoTip = false;
          }
        }
      }
      return resList;
    },
    //变更日志
    Openbgrz(value) {
      //打开变更日志弹窗
      
      this.row = value;
      this.changeConfig.dialogFormVisible = true;
      let params = {
        custId: this.FormModel.custId || "",
        modTypeFlag: "2",
        orderItemId: value.orderItemId,
        prodId: value.prodId,
        serviceOfferId: value.serviceOfferId,
        modType: JSON.parse(sessionStorage.getItem("ppmCondition")).modType, //非正常变更50200002,正常变更50200003
        pageInfo: { pageIndex: "1", pageSize: "10" },
      };
      this.SaveModifyList(params);
    },

    handlePageChange(val) {
      //变更日志翻页事件
      let params = {
        custId: this.FormModel.custId || "",
        modTypeFlag: "2",
        orderItemId: this.row.orderItemId,
        prodId: this.row.prodId,
        serviceOfferId: this.row.serviceOfferId,
        modType: JSON.parse(sessionStorage.getItem("ppmCondition")).modType, //非正常变更50200002,正常变更50200003
        pageInfo: { pageIndex: val.currentPage, pageSize: val.pageSize },
      };
      this.SaveModifyList(params);
    },

    async SaveModifyList(params) {
      //变更日志列表
      const result = await OrderService.SaveModifyList(params);
      
      if (result.code == 200) {
        let orderModifyLogs = result.meta.orderModifyLogs;
        this.changeConfig.tableData = [...orderModifyLogs];
        this.changeConfig.tablePage = {
          currentPage: result.meta.pageInfo.pageIndex,
          pageSize: result.meta.pageInfo.pageSize,
          rowCount: result.meta.pageInfo.rowCount,
        };
      }
    },
    //设置缓存
    setStorageItem(item, value) {
      let FormModel = JSON.parse(sessionStorage.getItem("FormModel"));
      FormModel[item] = value;
      sessionStorage.setItem("FormModel", JSON.stringify(FormModel));
    },
    //受理运营商
    async getAttrValueList(params) {
      //获取页面下拉框值
      let loadingInstance = Loading.service({ fullscreen: true });
      const result = await OrderService.getAttrValueList(params);
      loadingInstance.close();
      if (result.code == 200) {
        let attrValueList = result.meta.attrValueList;
        this.operatorsList = [...attrValueList];
      }
    },
    slyys() {
      //受理运营商点击事件
      this.setStorageItem("orderSourceId", this.FormModel.orderSourceId);
    },
    khmc() {
      //客户名称
      this.setStorageItem("custName", this.FormModel.custName);
    },
    khlxr() {
      //客户联系人
      this.setStorageItem(
        "contactName",
        this.FormModel.orderContactInfo[0].contactName
      );
    },
    khcontact() {
      //客户联系电话
      this.setStorageItem(
        "contactMobilePhone",
        this.FormModel.orderContactInfo[0].officePhone
      );
    },
    khaddress() {
      //客户联系地址
      this.setStorageItem(
        "custAddr",
        this.FormModel.orderContactInfo[0].contactAddress
      );
    },
    /**
     * 1加载业务经理配置选项
     */
    async loadBusiManageOptions(params) {
      const data = {
        orgId: this.user.orgId, //session里取
        postCode: "016_XMJLYWJL", //客户经理  014_KHJL    业务经理  016_XMJLYWJL
        pageSize: "20",
        pageIndex: "1",
        ...params,
      };
      let res = await OrderService.qryStaffList(data);
      if (res.code == 200) {
        this.busiManageConfig.tableData = res.meta.staffIdList || [];
      }
    },

    /**
     * 2加载客户经理配置选项
     */
    async loadCustManageOptions(params) {
      const data = {
        orgId: this.user.orgId, //session里取
        postCode: "014_KHJL", //客户经理  014_KHJL    业务经理  016_XMJLYWJL
        pageSize: "20",
        pageIndex: "1",
        ...params,
      };
      let res = await OrderService.qryStaffList(data);
      if (res.code == 200) {
        this.custManageConfig.tableData = res.meta.staffIdList || [];
      }
    },

    /**
     * 3加载项目经理配置选项
     */
    async loadProjectManageOptions(data) {
      
      let res = await OrderService.qryStaffList(data);
      if (res.code == 200) {
        // this.projectManageConfig.tableData = res.meta.resultObject.staffIdList || [];
        this.projectManageConfig.tableData = res.meta.staffIdList || [];
      }
      
    },

    /**
     * 4加载项目名称配置选项
     */
    async loadProjectNameOptions(data) {
      const params = {
        requestObject: {
          projectJson: {
            itemcode: data.itemcode || "",
            itemname: data.itemname || "",
            page: {
              pageNo: 1,
              pageSize: 10,
            },
          },
        },
      };
      let res = await OrderService.qryProjectList(params);
      /*res = {code: 200,meta: { returnJson: [
            {itemcode: "XYJACQZHX180801503",itemname: "无合同立项",itemdesc: "",applydate: "2017-01-01 00:00:00.0", },
       ],}, };*/
      if (res.code == 200) {
        this.projectNameConfig.tableData = res.meta || [];
      }
    },

    /**
     * 5加载商机配置选项
     */
    async loadSaleOptions(data) {
      let res = await OrderService.qryStaffList(data);
      if (res.code == 200) {
        this.saleConfig.tableData = res.meta.resultObject
          ? res.meta.resultObject.staffIdList
          : [];
      }
    },

    /**
     * 6加载合同编码配置选项
     */
    async loadContactCdOptions(params) {
      let booleanType = 0;
      if ("contractcode" in params || "contractname" in params) {
        booleanType =
          params.contractcode !== "" || params.contractname !== "" ? 1 : 0;
      }
      let obj = {
        requestObject: {
          contractJson: {
            contractcode: "contractcode" in params ? params.contractcode : "",
            contractname: "contractname" in params ? params.contractname : "",
            itemcode: "",
            itemname: "",
            type: booleanType,
            page: {
              pageNo: 1,
              pageSize: 10,
            },
          },
        },
      };
      let res = await OrderService.qryContractList(obj);
      
      if (res.code == 200) {
        this.contactCdConfig.tableData = res.meta || [];
      }
    },
    /**
     * 7.加载营销项目编码配置选项
     */
    async loadMarketProjectOptions(params){
      let obj = {
         PMCUSTNUMBER:this.FormModel.oldPartyCode,// 客户编码 oldPartyCode
		 		 PMCUST:this.FormModel.custName,//客户名称
		     PMCUSTMANAGERID:this.FormModel.custManagerId,//客户经理id  没填可以是空
		     PMCUSTMANAGER:this.FormModel.custManageName, //客户经理名称  没填可以是空
		     PMMANAGERID:this.FormModel.busiManagerId,   //项目户经理id   没填可以是空
		     PMMANAGER:this.FormModel.busiManageName, //项目经理名称   没填可以是空
		     CONTRACTCODE:this.FormModel.contactCd, //合同编码  没填可以是空
		     CONTRACTNAME:this.FormModel.contactName, //合同名称  没填可以是空
		     PMCODE:'PMCODE' in params ? params.PMCODE:'', //项目编码   没填可以是空
				 PMNAME:'PMNAME' in params ? params.PMNAME:'', //项目名称  没填可以是空
         pageIndex:"1",
				 pageSize:"10",
      }
       let res = await OrderService.getMarProInfo(obj);
       if (res.code == 200) {
        this.marketProjectNameConfig.tableData = res.meta.returnjson || [];
       }
    },
    /**
     * 8.加载营销子项目编码配置选项
     */
    async loadMarketSubprojectOptions(){
      let obj = {
         pmId:this.FormModel.marketProjectId,
         pageIndex:"1",
				 pageSize:"10",
      }
      let res = await OrderService.getMarSubProInfo(obj);
      if (res.code == 200) {
        this.marketSubprojectNameConfig.tableData = res.meta.returnjson || [];
      }
    },

    /**
     * 1业务经理回传ID
     *
     */
    getRowBusiManageHandler(row) {
      // this.busiManageModel.busiManagerId = row.staffId;
      this.FormModel.busiManagerId = row.staffId;
      this.SET_BUSIMANAGERID(row.staffId);
      this.SET_XBUSIMANAGEMODEL({
        busiManagerId: row.staffId,
        busiManageName: row.staffName,
      });
    },
    /**
     * 2客户经理回传ID
     */
    getRowCustManageHandler(row) {
      // this.custManageModel.custManagerId = row.staffId;
      this.FormModel.custManagerId = row.staffId;
      this.SET_CUSTMANAGERID(row.staffId);
      this.SET_XCUSTMANAGEMODEL({
        custManagerId: row.staffId,
        custManageName: row.staffName,
      });
    },

    /**
     * 3项目经理回传ID
     */
    getRowProjectManageHandler(row) {
      // this.projectModel.projectManage = row.id;
      this.FormModel.projectManage = row.id;
    },

    /**
     * 4项目名称回传ID
     */
    getRowProjectNameHandler(row) {
      this.FormModel.projectId = row.itemcode;
      this.FormModel.projectName = row.itemname;
      this.FormModel.bussDesc = row.itemdesc;
      this.setStorageItem("projectCode", row.itemcode); //项目ID
      this.setStorageItem("projectsName", row.itemname); //项目名称
      this.setStorageItem("bussDesc", row.itemdesc); //项目描述
    },

    /**
     * 5商机回传ID
     */
    getRowSaleHandler(row) {
      // this.saleModel.saleId = row.id;
      this.FormModel.saleId = row.id;
    },

    /**
     * 6合同编码回传ID
     */
    getRowContactCdHandler(row) {
      // this.contactModel.contactId = row.id;
      this.FormModel.contactName = row.contractname;
      this.FormModel.contactCd = row.contractcode;
      this.FormModel.contactNumberType = row.contracttype;
      this.ctNameDisable = true;
      this.setStorageItem("contractCd", row.contractcode); //合同编码
      this.setStorageItem("contractName", row.contractname); //合同名称
      this.setStorageItem("contractId", row.contractid); //合同ID
      this.setStorageItem("contactNumberType", row.contracttype); //合同编号类型
    },
    /**
     * 7.营销项目编码回传ID
     */
    getMarketProjectCode(row) {
        this.FormModel.marketProjectCode = row.pmCode;
        this.FormModel.marketProjectName = row.pmName;
        this.FormModel.marketProjectId = row.pmId;
        this.infoTip = false;
    },
     /**
     * 8.营销子项目编码回传ID
     */
    getmarketSubprojectCode(row) {
      this.FormModel.marketSubprojectCode = row.initProductCode;
      this.FormModel.marketSubprojectName = row.productName;
      this.FormModel.subProjectId = row.initProductId;
    },

    continuGD() {
      //继续改单
      this.$store.commit("orders/SET_STEPACTIVE2", 3);
      this.$router.push({
        path: "/ContinueChange",
      });
    },
    /**
     * 销售品信息查询
     */
    async qryOrderItem() {
      const result = await OrderService.qryOrderItem({
        custOrderId: this.FormModel.custOrderId,
        custSoNumber: this.FormModel.custSoNumber,
        statusCds: "101398", //在新建订单时，这个值时写死的：110095
        staffid: this.user.staffId, //从用户session中获取，员工号
        orgId: this.user.orgId, //从session中取
        custId: this.FormModel.custId || "",
        pageInfo: {
          pageIndex: this.pageInfo.pageIndex || 1,
          pageSize: this.pageInfo.pageSize || 10,
        },
      });
      if (result.code == 200) {
        //&& result.meta.pageInfo != undefined
        this.tableData = result.meta.offerOrderItems;
        this.pageInfo.pageSize = result.meta.pageInfo.pageSize;
        this.pageInfo.pageIndex = result.meta.pageInfo.pageIndex;
        this.pageInfo.rowCount = result.meta.pageInfo.rowCount;
      }
    },

    async createProject(beforeVerify) {
      //如果保存成功，返回0
      let rtnCode = 1;
      if (this.tableData.length < 0 || this.tableData.length == 0) {
        this.$message({
          message: "销售品列表为空无法保存",
          type: "warning",
        });
        return rtnCode;
      }
      const valid = this.validOrderItems();
      if (!valid) return rtnCode;

      //项目保存规则埋点
      var ruleParam = [
        {
          PUB_REQ: {
            TYPE: "GOVCRM.ORDERSET.OrdSave",
          },
          ORD_SAVE: {
            CUST_ID: this.FormModel.custId,
            SERVICE_OFFER_ID: "4010100000", //业务编码
            APPLY_INFO: this.FormModel.saleId + "", //商机编码
            ORD_LEN: this.tableData.length + "", // 所选订单数量
            CUST_SO_NUMBER: this.FormModel.custSoNumber + "", //流水号
            SOURCE_ID: this.FormModel.orderSourceId + "", // 受理运营商ID
            CONTACT_CD: this.FormModel.contactCd + "", // 合同号
            EMAIL: this.FormModel.orderContactInfo[0].contactEmail || "", // 邮箱 传值参照 create Project.js 1223行的 $("#CONTACT-E_MAIL").val()
            // "IS_BIND_WGZJ": "1", //是否捆绑受理网管专家 传值参照 create Project.js 1391行的 $("#ORDER-IS_BIND_WGZJ").val()
            // "LAIHAN_FLAG": "1", //客户来函属性 传值参照 create Project.js 1488行的 $('#ORDER-IS_LAIHAN_FLAG').val()
            OFFER_ID: "", //销售品ID  单个值
          },
          ORD_SAVE_PROD: {
            CUST_ID: this.FormModel.custId,
            SERVICE_OFFER_ID: "4010100000", //业务编码
            OFFER_ID:
              this.tableData.length > 0 ? this.tableData[0].offerId + "" : "", //销售品ID  单个值
            PROJECT_CODE:
              this.tableData.length > 0 ? this.FormModel.projectId + "" : "", //项目编码
            PROD_INST_ID:
              this.tableData.length > 0
                ? this.tableData[0].prodInstId + ""
                : "", //   传值参照 create Project.js 1505行的 $("#procProdInstId").val();
            ORD_PROD_INST_ID:
              this.tableData.length > 0
                ? this.tableData[0].ordProdInstId + ""
                : "", //   传值参照 create Project.js 1506行的 $("#groupProdInstId").val();
            CUST_SO_NUMBER: this.FormModel.custSoNumber + "", //流水号
            CONTACT_ID: this.FormModel.contactCd + "", //合同编码
          },
        },
      ];

      //调用规则平台
      let ruleCode = await this.callRule(ruleParam);
      
      if (ruleCode == 2) {
        //如果返回2校验不通过
        return rtnCode;
      }

      //直接校验通过继续之前逻辑
      //----原逻辑-----
      // this.loading = true;
      // let result = await OrderService.createProject(this.requestObject);
      let result = await OrderService.createProject(this.FormModel);
      
      if (result.code == 200) {
        this.loading = false;
        //准备返回成功code
        rtnCode = 0;
        if (result.meta.resultCode == 0) {
          const customerOrder = result.meta.resultObject.customerOrder;
          //保存成功记得CLEAR_XMODEL清除vuex中的状态值,保证创建其它订单时不被脏读
          this.CLEAR_XMODEL();
          // 跳转工单信息时,初始化该页面状态
          this.SET_DEALTYPE("DEAL");
          this.SET_QRYTYPE(1);
          this.SET_QRYVALUE(customerOrder.custSoNumber);
          this.SET_ORDERSTAGEID("");
          this.verifyModel = customerOrder;
          if (!beforeVerify) {
            sessionStorage.removeItem("FormModel"); //移除项目新建缓存
            this.$message({
              type: "success",
              message: "保存成功!",
            });
            this.$router.push({
              name: `custorder`,
              params: {
                customerOrder: result.meta.resultObject.customerOrder,
              },
            });
          }
        } else {
          this.$message({
            type: "error",
            message: "保存失败!" + result.meta.resultMsg,
          });
        }
      } else {
        this.loading = false;
        this.$message({
          showClose: true,
          message: "保存失败",
          type: "error",
        });
      }
      // -----原逻辑-------
      return rtnCode;
    },

    handleSizeChange(size) {
      this.pageInfo.pageSize = size;
    },

    handleCurrentChange(pageIndex) {
      
      this.pageInfo.pageIndex = pageIndex;
    },

    /**
     * 表格多选事件函数
     */
    handleSelectionChange(sel) {
      this.multipleSelection = sel;
      if (sel.length < 1) {
        this.deleteObj.custSoNumber = "";
        this.deleteObj.orderItemIds = "";
        this.deleteObj.staffId = "";
        this.deleteObj.custId = "";
      } else if (sel.length >= 1) {
        for (let i = 0; i < sel.length; i++) {
          this.deleteObj.custSoNumber = sel[i].custSoNumber;
          this.deleteObj.orderItemIds += sel[i].orderItemId + ",";
          this.deleteObj.staffId = this.user.staffId;
          this.deleteObj.custId = sel[i].custId;
        }
      }
    },

    /**
     * 单条删除
     */
    doDel(row) {
      var orderItemIds = row.orderItemId;
      var reqMap = {
        orderItemIds: orderItemIds,
        custSoNumber: row.custSoNumber,
        staffId: this.user.staffId + "",
        custId: row.custId,
      };
      
      this.isContent.ODKInfo = {};
      this.isContent.ODKInfo.reqMap = reqMap;
      this.isContent.ODKInfo.deleteType = "delOrder";
      this.isContent.content = "DeletePage";
      this.pendItemVisible = true;
    },
    /**
     * 模板导出
     */
    templateDown(row) {
      this.isContent.ODKInfo = {};
      // this.isContent.ODKInfo.reqMap = reqMap;
      // this.isContent.ODKInfo.deleteType = "delOrder";
      this.isContent.width = "1000px";
      this.isContent.content = "templateQuery";
      this.pendItemVisible = true;
    },
    /**
     * 单条编辑
     */
    doEdit(row) {},
    /**
     * 批量删除
     */
    doBatchDel() {
      

      if (this.multipleSelection.length == 0) {
        this.$message({
          type: "warn",
          message: "至少选择一条订单!",
        });
        return;
      }

      var orderItemIds = "";
      for (var i = 0; i < this.multipleSelection.length; i++) {
        if (i == 0) {
          orderItemIds += this.multipleSelection[i].orderItemId;
        } else {
          orderItemIds += "," + this.multipleSelection[i].orderItemId;
        }
      }

      var reqMap = {
        orderItemIds: orderItemIds,
        custSoNumber: this.multipleSelection[0].custSoNumber,
        staffId: this.user.staffId + "",
        custId: this.multipleSelection[0].custId,
      };
      
      this.isContent.ODKInfo = {};
      this.isContent.ODKInfo.reqMap = reqMap;
      this.isContent.ODKInfo.deleteType = "delOrder";
      this.isContent.content = "DeletePage";
      this.pendItemVisible = true;
    },
    async doCopyOrder() {
     if(sessionStorage.getItem('proFlag') == '5G'){
          this.$message({
             type: "warn",
             message: "行业5G消息产品不能操作复制功能!",
          });
          return;
      }        
      if (this.multipleSelection.length == 0) {
        this.$message({
          type: "warn",
          message: "必须选中一条记录然后再复制！",
        });
        return;
      }
      var reqMap = {
        orderItemId: this.multipleSelection[0].orderItemId,
        custSoNumber: this.multipleSelection[0].custSoNumber,
        custOrderId: this.multipleSelection[0].custOrderId,
        custId: this.multipleSelection[0].custId,
      };
      this.isContent.ODKInfo = {};
      this.isContent.ODKInfo.reqMap = reqMap;
      this.isContent.content = "CopyOrder"; //对应的Vue
      this.pendItemVisible = true; //弹框显示
    },
    eventShowpop() {
      
    },

    //调用规则平台通用方法 lb
    async callRule(ruleParam) {
      this.loading = true;
      const result = await OrderService.rulePlatfromCheck(ruleParam);
      let ruleCode = result.code;
      let ruleMsg = result.msg;
      //直接通过校验
      if (ruleCode != 0) {
        this.loading = false;
        //校验结果有警告或者拒绝，弹窗提示
        //图标样式
        let iconType = "warning";
        if (ruleCode == 2) {
          iconType = "error";
        }
        await this.$confirm(ruleMsg, "提示", {
          confirmButtonText: "确定",
          type: iconType,
        })
          .then(() => {})
          .catch(() => {});
      }
      return ruleCode;
    },

    //保存送审核
    async doCreateAndVerify() {
       if(sessionStorage.getItem('proFlag') == '5G'){
          this.$message({
             type: "error",
             message: "行业5G消息产品不能操作保存送审核!",
          });
          return;
      }    
      const valid = this.validOrderItems();
      if (!valid) return;
      // const loading = this.$loading({
      //   lock: true,
      //   text: "正在进入项目保存和送审核流程.....",
      //   spinner: "el-icon-loading",
      //   background: "rgba(0, 0, 0, 0.5)",
      // });
      // 1.先进行项目保存
      let createSaveRtnCode = await this.createProject(true);
      
      //保存失败直接返回
      if (createSaveRtnCode == 1) {
        
        return;
      }

      //送审核规则埋点（待处理工单规则埋点）
      var ruleParam = [
        {
          PUB_REQ: {
            TYPE: "GOVCRM.TASK.taskLevel",
          },

          ORDER_AUDIT_CHECK: {
            TASK_ID: this.verifyModel.taskId + "",
            CUST_SO_NUMBER: this.verifyModel.custSoNumber + "",
            BATCH_NO: this.verifyModel.batchNbr + "",
            CUST_ORDER_TYPE: this.FormModel.custOrderType + "",
            TASK_ID2: this.verifyModel.taskId + "",
            CUST_ID: this.verifyModel.custId + "",
          },
        },
      ];
      //调用规则平台
      let ruleCode = await this.callRule(ruleParam);
      this.loading = false;
      
      if (ruleCode == 2) {
        //如果返回2不打开送审核页面，直接跳转到待处理页面，否则打开送审核页面
        
        return;
      }

      if (this.verifyModel) {
        this.isContent.ODKInfo = { ...this.verifyModel };
        this.isContent.CTOInfo = { ...this.verifyModel };
        // this.isContent.CTOInfo.custId = this.custModel.custMsg.custId;
        this.isContent.CTOInfo.custId = this.FormModel.custId;
        this.isContent.CTOInfo.cb = () => {
          sessionStorage.removeItem("FormModel"); //移除项目新建缓存
          this.$message({
            type: "success",
            message: "保存成功!",
          });
          this.$router.push({
            name: `custorder`,
            params: {
              customerOrder: this.verifyModel,
            },
          });
        };
        this.isContent.width = "800px";
        this.isContent.content = "SendAudit";
        //3.进入送审核流程
        this.pendItemVisible = true;
      }
      // loading.close();
    },

    /**
     * 校验订单项信息
     */
    validOrderItems() {
      let result = false;
      let adodrFrom = this.$refs.morepanel.$refs.adodrFrom;
      adodrFrom.validate((valid) => {
        result = valid;
      });
      return result;
    },
    /**
     * 删除
     */
    deleteClick() {
      if (
        this.deleteObj.custSoNumber == "" &&
        this.deleteObj.orderItemIds == "" &&
        this.deleteObj.staffId == "" &&
        this.deleteObj.custId == ""
      ) {
        this.$message({
          message: "请选择销售品",
          type: "warning",
          showClose: true,
        });
      } else {
        this.deleteData();
      }
    },
    async deleteData() {
      const result = await OrderService.delOrder(this.deleteObj);
      if (result.code == 200) {
        this.qryOrderItem();
        this.deleteObj.custSoNumber = "";
        this.deleteObj.orderItemIds = "";
        this.deleteObj.staffId = "";
        this.deleteObj.custId = "";
        this.$message({
          message: result.meta.resultMsg,
          type: "success",
          showClose: true,
        });
      } else {
        this.$message({
          message: result.meta.resultMsg,
          type: "warning",
          showClose: true,
        });
        
      }
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .left {
  span {
    padding-left: 0;
    &:before {
      display: none;
    }
  }
}
.tbl-title {
  font-size: $fontSize_v2;
  font-weight: 600;
}
.m-content-box {
  position: relative;
  padding-bottom: 0.6rem;
}
.footBtn {
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 10px 0;
  text-align: center;
  z-index: 99;
  background-color: rgba($color: #ccc, $alpha: 0.5);
}
.table-title {
  height: 40px;
  border-bottom: 1px solid #90939947;
  margin-bottom: 8px;
  p {
    height: 40px;
    line-height: 20px;
  }
}

.bgrz {
  color: $blue;
  cursor: pointer;
}

::v-deep .changeDialog {
  min-height: 5rem;
  overflow-y: scroll;
  .el-dialog__header {
    text-align: left;
  }
  .el-dialog__title {
    border-left: 3px $blue solid;
    padding-left: 0.1rem;
  }
}
/*弹窗样式*/
.import-container {
  .instructions {
    margin-left: 10px;
  }
  .publicColor {
    color: red;
  }
}
.primaryButton {
  text-align: center;
  margin-top: 10px;
  .el-button--primary {
    width: 100px;
  }
}
.exhibition {
  .is-disabled {
    width: 600px;
  }
}
.upload-demo {
  width: 600px;
  /*margin-top: -10px;*/
  .el-upload__tip {
    height: 15px;
    margin-top: -10px;
    color: red;
  }
}
.el-radio-group {
  margin-left: 10px;
  display: inline;
}
.lineFeed {
  display: block;
  margin-top: -10px;
}
.typeTitle {
  ::v-deep .el-form-item__label {
    margin-top: 6px;
  }
}
.batchNumber {
  width: 300px;
  height: 30px;
}
</style>
